package muslim30;

import java.io.IOException;
import java.util.HashMap;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class PrmNationsServlet extends HttpServlet {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 6246140270990607883L;

	
	private static final HashMap<String, String> nationName = new HashMap<String, String> () {
		
		/**
		 * 
		 */
		private static final long serialVersionUID = -5349273760556141642L;

		{
			put("1", "syria");
			put("2", "iraq");
			put("3", "jordan");
			put("4", "saudi");
			put("5", "yemen");
			put("6", "ip");
			put("7", "lebanon");
			put("8", "egypt");
			put("9", "kurds");
			put("10", "turkey");
			put("11", "azerbai");
			put("12", "afhan-paki");
			put("13", "iran");
			put("14", "tajik");
			put("15", "uzbek");
			put("16", "kazak");
			put("17", "turk");
			put("18", "kyrgyz");
			put("19", "n-india");
			put("20", "uygur");
			put("21", "hui");
			put("22", "maghreb");
			put("23", "n-caucasus");
			put("24", "volga-ural");
		}
	};
	
	
	public void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws IOException {
		
		String nationCode = request.getParameter("code");
		
		if(nationCode == null)
			nationCode = "1";
		
		PrmDBMgr mDB = new PrmDBMgr();
		//String strQuery = "select * from ramadan_bbs_nation where year = 2013, nation = '" + nationName.get(nationCode) + "'";
		/*if(tablename.containsKey(nationName))
			tblname = tablename.get(nationName);
		else
			tblname = "ramadan_n4";*/
		
		try {
			String json = mDB.getContentsAsJSONFromRamadanBBSNation("2013", nationName.get(nationCode));
			response.setContentType("text/html;charset=euc-kr");
			response.getWriter().print(json);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}	
}
